package com.itboye.system.crypt;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

/**
 * Created by hebidu on 16/7/20.
 */
public class ByPasswordCrypt {

//    function think_ucenter_md5($str, $key = 'ThinkUCenter'){
//        return '' === $str ? '' : md5(sha1($str) . $key);

    public static String encode(String password,String salt) throws UnsupportedEncodingException, NoSuchAlgorithmException {

        if(password.length() == 0){
            return password;
        }

        String sha1Pwd = Sha1Crypt.encode(password);

        return MD5Crypt.encode(sha1Pwd+salt);
    }
}
